let name;
let f;
let k = 0;
let F = true;
let names = [
    "刘闵浩", "刘博宇", "蒋浩铭", "付振庭", "戴君帆", "秦宇杉","陈璿如" ,"杨心杨", "谈镇豪", "何思源", "曾子云", "周子琪", "唐菡梓", "周琳珊", "周承熠", "罗鑫睿", "朱万翔", "冷治霖", "陈思宇", "许浩轩", "满仁彬", "徐语彤", "周杨皓", "荀译萱", "陈卓", "黄鑫睿", "张嘉诺", "周澍雨", "李宗铃", "唐维骏", "叶一禅", "刘依依", "王舒悦", "邹义", "马梓轩", "易思彤", "覃朗", "徐子钦", "胡雨桐", "赵梓含", "杨书聿", "张珂鱼", "龙义远", "王领西", "翟一航", "袁康愉", "张俊豪", "王心妍", "刘庆洋睿", "胡烔彰", "张有峰"];

//生成当前名单
function A() {
    for (let i = 0; i < names.length; i++) {
        if (names[i].length > 1) {
            let x = document.createElement("button");
            x.id = k + '';
            let t = document.createTextNode(names[i]);
            x.appendChild(t);
            document.getElementById("D1").appendChild(x);
            if ((i + 1) % 12 == 0 & i != 0) {
                let x = document.createElement("br");
                document.getElementById("D1").appendChild(x);
            }
            k++;
        } else {
            let x = document.createElement("button");
            let t = document.createTextNode(names[i]);
            x.appendChild(t);
            document.getElementById("D1").appendChild(x);
            if ((i + 1) % 12 == 0 & i != 0) {
                let x = document.createElement("br");
                document.getElementById("D1").appendChild(x);
            }
        }
    }
}

function change() {
    let ID = Math.floor(Math.random() * k);
    name = document.getElementById(ID + '').innerHTML;
    for (let i = 0; i < k; i++) {
        if (ID != i) {
            document.getElementById(i + '').style.cssText = "background:#FFFAF0";
        }
        document.getElementById(ID + '').style.cssText = "background:#f00";

    }
}

function begin() {
    document.getElementById("P2").style.cssText = "background: #ffd30b"
    document.getElementById("P2").innerHTML = "";
    if (F) {
        f = setInterval(change, 50);
        F = false;
    }
}

function end() {
    F = true;
    document.getElementById("P2").style.cssText = "background: #ffd30b"
    document.getElementById("P2").innerHTML = name;
    clearInterval(f);
}
